/*
  This example comes from a short article series in the Linux 
  Gazette by Richard A. Sevenich and Christopher Lopes, titled
  "Compiler Construction Tools". The article series starts at

  http://www.linuxgazette.com/issue39/sevenich.html

  Small changes and updates to newest JFlex+Cup versions 
  by Gerwin Klein
*/

/*
  Commented By: Christopher Lopes
  File Name: Main.java
  To Create: 
  After the scanner, lcalc.flex, and the parser, ycalc.cup, have been created.
  > javac Main.java
  
  To Run: 
  > java Main test.txt
  where test.txt is an test input file for the calculator.
*/
   
import java.io.*;
import java.util.*;
   
public class Main {
        public static void main(String[] args) {
			String fileName = "C:\\wamp\\www\\PHPTestes\\index.php";
            
            try {
				PhpLexer lexer = new PhpLexer(new FileReader(fileName));
				lexer.setFileName(fileName);
                PhpParser parser = new PhpParser(lexer);
				ParseNode rootNode = (ParseNode) parser.parse().value;
				
				SemanticAnalyzer instance = SemanticAnalyzer.getInstance();
				if (instance.validate()) {
					List<String> erros = instance.getErros();

				}
				
            } catch (FileNotFoundException e) {
                System.err.println("File not found: " + fileName);
                System.exit(1);
            } catch (Exception e) {
                System.err.println("Error parsing " + fileName);
                System.err.println(e.getMessage());
                e.printStackTrace();
                System.exit(1);
            }

        }
}

